package com.lge.pitchingcoins.util.lockkey;

import android.app.Activity;

import com.lge.pitchingcoins.util.Util;

public class HomeKeyLockForKK implements IHomeKeyLock {
    @Override
    public boolean setHomeKeyLock(boolean isLocked, IWindowManagerLayoutParams windowManagerLayoutParams, Activity activity) {
        int lockForHomeKey = -1;
        
        try {
            lockForHomeKey = Class.forName(Util.CLASS_NAME_KEYEXCEPTIONCONSTANTS).getDeclaredField("BYPASS_HOME_KEY").getInt(null);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        
        if (isLocked) {
            windowManagerLayoutParams.addLayoutParamExtendFlag(lockForHomeKey);
        } else {
            windowManagerLayoutParams.setLayoutParamExtendFlag(0);
        }
        activity.getWindow().setAttributes(windowManagerLayoutParams.getAttributes());
        
        return true;
    }
}